//
//  WYCHeaderFooterView.m
//  初试
//
//  Created by 中企互联 on 2017/10/17.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCHeaderFooterView.h"

@implementation WYCHeaderFooterView

+(instancetype)headFootViewTableView:(UITableView *)tableView section:(NSInteger)section
{
    static NSString * Head = @"h";
    WYCHeaderFooterView * headerFooterView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:Head];
    if (headerFooterView == nil)
    {
        headerFooterView = [[WYCHeaderFooterView alloc] initWithReuseIdentifier:Head withSection:section];;
    }
    
    return headerFooterView;
    
}

- (void)setGroup:(WYCTransLationModel *)group
{
    _group = group;
    NSString *MonthStr =@"快速消费";
    _MonthLabel.text = MonthStr;

    if ([group.status isEqualToString:@"0"]) {
        _NumberLabel.text = @"提现成功";
        _NumberLabel.textColor = [UIColor blueColor];
    }
    else if ([group.status isEqualToString:@"1"])
    {
        _NumberLabel.text = @"创建";
        _NumberLabel.textColor = [UIColor blueColor];
    }
    else if ([group.status isEqualToString:@"2"])
    {
        _NumberLabel.text = @"提现中";
        _NumberLabel.textColor = [UIColor blueColor];
    }
    else if ([group.status isEqualToString:@"3"])
    {
        _NumberLabel.text = @"扣款失败";
        _NumberLabel.textColor = [UIColor redColor];
    }
    else if ([group.status isEqualToString:@"4"])
    {
        _NumberLabel.text = @"结算失败";
        _NumberLabel.textColor = [UIColor redColor];
    }
    _TimeLabel.text = [NSString stringWithFormat:@"%@", group.createTime];
    _MoneyLabel.text = [NSString stringWithFormat:@"+%.2f",[group.amount doubleValue]];
    
    
}

-(id)initWithReuseIdentifier:(NSString *)reuseIdentifier withSection:(NSInteger)section
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier])
    {
        self.contentView.backgroundColor = [UIColor whiteColor];

        //九月账单
        _MonthLabel = [[UILabel alloc] init];
        _MonthLabel.frame = CGRectMake(40 * px, 40 * px, ScreenWidth / 2, 70 * px);
        _MonthLabel.font = [UIFont systemFontOfSize:BigMiddleFont];
        [self.contentView addSubview:_MonthLabel];
        
        
        //时间日期
        _TimeLabel = [[UILabel alloc] init];
        _TimeLabel.frame = CGRectMake(_MonthLabel.x, CGRectGetMaxY(_MonthLabel.frame) + 20 * px, _MonthLabel.width, 40 * px);
        _TimeLabel.font = [UIFont systemFontOfSize:SmallFont];
        _TimeLabel.textColor = WYCRGBColor(163, 163, 163);
        [self.contentView addSubview:_TimeLabel];
        
        
        //金额
        _MoneyLabel = [[UILabel alloc] init];
        _MoneyLabel.frame = CGRectMake(ScreenWidth - 120, _MonthLabel.y+10, 120, _MonthLabel.height);
        _MoneyLabel.textAlignment = NSTextAlignmentCenter;
        _MoneyLabel.font = [UIFont systemFontOfSize:BigMiddleFont];
        [self.contentView addSubview:_MoneyLabel];
        
        //金额账单
        _NumberLabel = [[UILabel alloc] init];
        _NumberLabel.frame = CGRectMake( ScreenWidth/2-60,40*px, 120, _MonthLabel.height);
        _NumberLabel.font = [UIFont systemFontOfSize:WyzFont];
        _NumberLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_NumberLabel];
        
        UIView  *line = [[UIView alloc]initWithFrame:CGRectMake(0, 60, ScreenWidth, 0.5)];
        line.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:line];
        
    }
    return self;
}

- (void)openClick{
    WYCLogFunc;
    self.group.isOpen = !self.group.isOpen;
    if ([self.delegate respondsToSelector:@selector(reloadTableView)]) {
        [self.delegate reloadTableView];
    }
    
}





-(void)layoutSubviews
{
    [super layoutSubviews];
    self.OpenButton.frame = self.bounds;
}

///**
// *  当一个控件被添加到父控件中就会调用
// */
-(void)didMoveToSuperview
{
    
    if (self.group.isOpen)
    {
        _OpenButton.imageView.transform = CGAffineTransformMakeRotation(M_PI_2);
        
    }else{
        _OpenButton.imageView.transform = CGAffineTransformMakeRotation(0);
        
        
    }
}
@end
